package other;

import java.util.*;

public class D230910 {
    // 求中位数
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        for (int i = 0; i < n; i++) {
            int m = in.nextInt();
            int[] a = new int[m];
            HashMap<Integer, Integer> map = new HashMap<>();
            for (int j = 0; j < m; j++) {
                a[j] = in.nextInt();
                map.put(a[j], map.getOrDefault(a[j], 0) + 1);
            }
            int[] b = new int[m - 1];
            int size = m;
            func(map, size--);
            for (int j = 0; j < m - 1; j++) {
                int index = in.nextInt();
                int tmp = a[index - 1];
                map.put(tmp, map.getOrDefault(tmp, 0) - 1);
                func(map, size--);
            }

            System.out.println();
        }
    }
    private static void func(HashMap<Integer, Integer> map, int n) {
        int[] arr = new int[n];
        int i = 0;

        for (Map.Entry<Integer, Integer> entry : map.entrySet()) {
            for (int j = 0; j < entry.getValue(); j++) {
                arr[i++] = entry.getKey();
            }
        }
        int mid = n / 2;
        if (n % 2 == 1) {
            System.out.print(arr[mid] + " ");
        } else {
            double d = ((double) arr[mid] + (double) arr[mid - 1]) / 2;
            if (d == (int) d) {
                System.out.print((int) d + " ");
            } else {
                System.out.printf("%.1f ", d);
            }
        }
    }
}
